package yt.demo.appcoresystem.impl;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yt.demo.appcommondb.base.BaseService;
import yt.demo.appcommondb.vo.ConditionVO;
import yt.demo.appcoresystem.entity.SystemOperLog;
import yt.demo.appcoresystem.mapper.SystemOperLogMapper;
import yt.demo.appcoresystem.service.ISystemOperLogService;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class SystemOperLogService extends BaseService<SystemOperLog, SystemOperLogMapper> implements ISystemOperLogService {

    @Autowired
    public SystemOperLogService(SystemOperLogMapper mapper) {
        super(mapper, SystemOperLog.class);
    }

    @Override
    protected List<ConditionVO<SystemOperLog, ?>> whereConditions(SystemOperLog params) {
        List<ConditionVO<SystemOperLog, ?>> conditions = new ArrayList<>();
        if (ObjectUtil.isNotEmpty(params.getServiceName())) {
            conditions.add(ConditionVO.createCondition(SystemOperLog::getServiceName, "like", params.getServiceName()));
        }
        if (ObjectUtil.isNotEmpty(params.getResponseCode())) {
            conditions.add(ConditionVO.createCondition(SystemOperLog::getResponseCode, "eq", params.getResponseCode()));
        }
        if (ObjectUtil.isNotEmpty(params.getSearchTime())) {
            conditions.add(ConditionVO.createCondition(SystemOperLog::getCreateTime, "bet", params.getSearchTime()));
        }
        return conditions;
    }

}
